﻿/*******************************************************************************
 * @file zporting.h
 * @brief libzmodem 移植相关
 *******************************************************************************
*/

#ifndef __PORTING_H__
#define __PORTING_H__

#include <stdio.h>
#include "usart.h"

#define STDIN_FILENO   0
#define STDOUT_FILENO  1
#define STDERR_FILENO  2

struct stat
{
    long		st_size;	/* Size of file, in bytes.  */
    unsigned int offset;
    unsigned char *datas;
};


/* libzmodem 接收数据使用的是 getchar 所以需要重定向标准输入到输入源，如串口 */

__STATIC_INLINE int fileno(FILE *stream)
{
    return 123;
}

__STATIC_INLINE unsigned int sleep(unsigned int seconds)
{
    return 0;
}

size_t fwrite2(const void *ptr, size_t size, size_t nmemb, FILE *stream);
int putc2(int c, FILE *stream);
int fstat(int fd, struct stat *statbuf);

void putdatas(const char *data, size_t len);


#endif // PORTING_H

